# Virtual slot assignment takes place here if specified in the bdf,
# else it is done inside qemu-xen, as it knows which slots are free
pci = []
+ vfunc = 0;
func_list = pci_func_list_process(pci_dev_str, template,
pci_dev_info['func'])
for func in func_list:
pci_dev = template.copy()
pci_dev['func'] = "0x%x" % func
- if len(func_list) == 1:
- # For single-function devices vfunc must be 0
- vfunc = 0
- else:
- # For multi-function virtual devices,
- # identity map the func to vfunc
- vfunc = func
if pci_dev_info['vdevfn'] == '':
vdevfn = AUTO_PHP_SLOT | vfunc
else:
pci_dev['vdevfn'] = "0x%02x" % vdevfn
pci.append(pci_dev)
+ vfunc += 1
# For pci attachment and detachment is it important that virtual
# function 0 is done last. This is because is virtual function 0 that
if len(devs) == 0:
return
- devs.sort(None,
- lambda x: (x['vdevfn'] - PCI_FUNC(x['vdevfn'])) << 32 |
- PCI_BDF(x['domain'], x['bus'], x['slot'], x['func']))
+ def f(x):
+ # The vfunc shouldn't be used for ordering if the vslot hasn't been
+ # assigned as the output looks odd beacuse the vfunc isn't reported
+ # but the (physical) function is.
+ if x['vdevfn'] & AUTO_PHP_SLOT:
+ vdevfn = AUTO_PHP_SLOT
+ else:
+ vdevfn = x['vdevfn']
+ return (vdevfn << 32) | \
+ PCI_BDF(x['domain'], x['bus'], x['slot'], x['func'])
+ devs.sort(None, f)
has_vdevfn = False
for x in devs: